<template>
  <div>
    <el-table :data="recordList" border tooltip-effect="darkTable">
      <el-table-column :label="$t('节点名称')" align="center" prop="taskName" />
      <el-table-column :label="$t('用户名称')" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.approver ? scope.row.approver[0] : '' }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('审批意见')" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.commentList ? scope.row.commentList[0] : '' }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 预览附件 -->
    <OnlinePreview ref="OnlinePreview" :preview-tit="previewTit" />
  </div>
</template>

<script>
import { showNodeFormAssignees } from '@/api/act/process/actProcess'
  import { downLoadFileOpen } from '@/utils/zipdownload'
  export default {
    name: 'ActModelFlowFormDetails',
    data() {
      return {
        recordList: [],
        previewTit: undefined,
        taskName: []
      }
    },
    created() {
    },
    mounted() {
    },
    methods: {
      getList(queryData) {
        console.log('queryData', queryData)
        // 根据流程实例ID和节点aid获取没有审批过的节点数据（节点名称已经对应的审批人）
        showNodeFormAssignees(queryData.processKey, queryData.sid).then(response => {
          this.recordList = response.data
          this.formatApproval(this.recordList)
        })
      },
      // 预览附件
      onlinePreview(row) {
        this.$refs.OnlinePreview.onlinePreviewFile(row.id)
      },
      down(row) {
        downLoadFileOpen(row.id)
      },
      formatApproval(recordList) {
        for (let i = 0; i < recordList.length; i++) {
          var commentList = recordList[i].commentList
          if (commentList != null) {
            for (let j = 0; j < commentList.length; j++) {
              if (commentList[j].message.indexOf('\n') !== -1) {
                commentList[j].message = commentList[j].message.replace('审批意见:', '审批意见:\n')
              }
            }
          }
        }
      }

    }
  }
</script>
<style lang="sass" scoped>

</style>
